package com.cloud.cmt.usermanage.controller;

import com.angela.cloud.common.base.ResultMessage;
import com.cloud.cmt.usermanage.entity.vo.AuditManagementVO;
import com.cloud.cmt.usermanage.service.UserManagementService;
import io.swagger.annotations.*;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 浙江卓锐科技股份有限公司 版权所有 © Copyright 2017<br>
 * 说明: <br>
 * 项目名称: cloud-maintenance <br>
 * 创建日期: 2017年10月29日 16:04 <br>
 * 作者: <a href="6492178@gmail.com">汪萌萌</a>
 */
@RestController
@RequestMapping("/user_management")
@Api(tags = "user_management", description = "用户管理相关操作-by汪萌萌")
public class UserManagementCtl {
    @Resource
    private UserManagementService userManagementService;

    @GetMapping("/audit/{account_status}")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "conditions", value = "查询条件", dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "page", value = "页码(0开始)", dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "size", value = "页面大小", dataType = "int", paramType = "query")
    })
    @ApiOperation(value = "获取企业列表", notes = "如同时获取多种状态则以逗号分隔,如:同时获取待审核和审核未通过企业列表/user_management/audit/1,2")
    public ResultMessage<List<AuditManagementVO>> getAuditManagementsByAccountStatus(@PageableDefault Pageable pageable, @ApiParam(name = "account_status", value = "账户状态(1:待审核,2:审核未通过,4:试用中,5:使用中,6:已流失)") @PathVariable(name = "account_status") int[] accountStatus, @RequestParam(required = false) String conditions) {
        return userManagementService.getAuditManagementsByAccountStatus(pageable, accountStatus, conditions);
    }

    @GetMapping("/detail/{id}")
    @ApiOperation(value = "获取用户详情")
    public ResultMessage getEnterpriseDetailById(@PathVariable Long id) {
        return userManagementService.getEnterpriseDetailById(id);
    }

    @GetMapping("/auditPass/{id}")
    @ApiOperation(value = "审核通过")
    public ResultMessage auditPassById(@PathVariable Long id) {
        return userManagementService.auditPassById(id);
    }

    @GetMapping("/auditNotPass/{id}")
    @ApiOperation(value = "审核不通过")
    public ResultMessage auditNotPassById(@PathVariable Long id) {
        return userManagementService.auditNotPassById(id);
    }

    @GetMapping("/enableById/{id}")
    @ApiOperation(value = "启用")
    public ResultMessage enableById(@PathVariable Long id) {
        return userManagementService.removeBlackListById(id);
    }

    @GetMapping("/disableById/{id}")
    @ApiOperation(value = "禁用")
    public ResultMessage disableById(@PathVariable Long id) {
        return userManagementService.addBlackListById(id);
    }
}
